package cn.com.nes.site.entity.em.project;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目关系数据生成类型 枚举
 *
 */
public enum ProjectRelationDataTypeEnum {

    EXCEL(0, "excel导入"),
    SYSTEM_GENERATED(1, "系统生成"),
    MANUAL_OPERATION(2, "人工操作"),
    ;

    private final Integer key;
    private final String value;

    ProjectRelationDataTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static ProjectRelationDataTypeEnum getKey(String key) {
        Map<String, ProjectRelationDataTypeEnum> map = new HashMap<>();
        for (ProjectRelationDataTypeEnum projectRelationTypeEnum : values()) {
            map.put(String.valueOf(projectRelationTypeEnum.getKey()), projectRelationTypeEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的项目关系类型");
        }
        return map.get(key);
    }

}
